package com.h2cloud.record;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Arrays;
import java.util.Stack;

/**
 * @author: wulongkai
 * @create: 2023-04-06 16:25
 **/
public class test1 {
    public static void main(String[] args) throws JsonProcessingException {

//        person p1 = new student1();
//        p1.getBiz();
//
//        person p = new student();
//        p.getBiz();

//        List<Object> newList = new ArrayList<>();
//        newList.add("heelo");
//        newList.add("longkai");
//        System.out.println("newList.toString() = " + newList.toString());
//        String s =  newList.stream().map(Object::toString).collect(Collectors.joining(","));
//        System.out.println("s = " + s);
//        Object o = p1;

//        person cast = person.class.cast(o);
//        System.out.println("cast = " + cast.a);


//        // 获取当前的本地时间
//        LocalDateTime nowTime = LocalDateTime.now();
//        long updateTime = nowTime.toInstant(ZoneOffset.UTC).toEpochMilli();
//        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(updateTime), ZoneId.of("UTC"));
//        System.out.println("localDateTime = " + localDateTime);
//
//
//        List list = new Gson().fromJson((String) "", List.class);
//        System.out.println(list);
//        String.join(",", list);

//        int[] arr = {0, 2, 36, 2, 5, 9, 8};
//        int[] nextSecondLargest = getNextSecondLargest(arr);
//        System.out.println("Arrays.toString(nextSecondLargest) = " + Arrays.toString(nextSecondLargest));

//        try {
//            System.in.read();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        System.out.println("hello");


//        List<String> idList = new ArrayList<>();
//        idList.add("1518929253746348032");
//        idList.add("1518929253700218880");
//        idList.add("1518929253754736640");
//        String s = new GsonBuilder().
//                setLongSerializationPolicy(LongSerializationPolicy.STRING).
//                create().toJson(idList);
//        System.out.println("s = " + s);

//        String preNodeName = "节点1/节点2（并行节点）";
//        String nodeName = "节点3";
//        String newName = preNodeName.replace("（并行节点）", "") + "/" + nodeName + "（并行节点）";
//        System.out.println("newName = " + newName);

//        Map<Integer, String> number2NodeInfo = new TreeMap<>();
//        number2NodeInfo.put(1, "1");
//        number2NodeInfo.put(2, "2");
//        number2NodeInfo.put(3, "3");
//        number2NodeInfo.put(4, "4");
//        List<String> collect = new ArrayList<>(number2NodeInfo.values());
//        System.out.println("collect = " + collect);

        String[] strings = {"答案1", "答案12"};

        // Json字符串
        String jsonStr = "[{\"type\":\"Subject\",\"label\":\"试用期转正考核 - 上级评估\",\"name\":\"tEdt1626099535304\",\"value\":\"\",\"title\":\"标题名称\",\"showDeleteIcon\":false,\"attributes\":{\"fontWeight\":600,\"fontSize\":18,\"color\":\"#303133\",\"emptyError\":false,\"width\":\"24\",\"required\":true},\"key\":\"IIgK1626099535304\"},{\"type\":\"Instructions\",\"name\":\"Fcwb1626099548106\",\"title\":\"说明\",\"showDeleteIcon\":false,\"value\":\"\",\"label\":\"说明\",\"attributes\":{\"fontWeight\":500,\"fontSize\":14,\"color\":\"#303133\",\"width\":\"24\",\"placeholder\":\"您好，请您根据员工试用期内的工作表现，填写下述评价问卷对该员工进行试用期转正评估。\\n① 如果您无法一次性完成问卷或需要对评价结果进行修改，请先将问卷保存备用。\\n② 评估问卷完成后，请仔细检查。最终确认无误后点击提交按钮。一经提交，将无法修改。\\n③ 同意员工转正，请选择通过，并点击提交\\n④ 不同意员工转正，请选择不通过，并点击提交，流程将结束。请及时与部门HRBP沟通员工不通过试用期的情况。\",\"emptyError\":false,\"required\":true,\"backgroundColor\":\"transparent\"},\"key\":\"jaLk1626099548106\"},{\"type\":\"Instructions\",\"name\":\"RasN1626099588746\",\"title\":\"说明\",\"showDeleteIcon\":false,\"value\":\"\",\"label\":\"说明\",\"attributes\":{\"fontWeight\":500,\"fontSize\":14,\"color\":\"#303133\",\"width\":\"24\",\"placeholder\":\"说明：以下所有打分题，评分标准为 A：优秀  B：良好 C：合格 D：部分合格 E：不符合标准\",\"emptyError\":false,\"required\":true,\"backgroundColor\":\"transparent\"},\"key\":\"iZeR1626099588746\"},{\"type\":\"SingleRadio\",\"label\":\"【专业能力】 （必填）\",\"name\":\"ZBLB1626099584383\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"ZyIf1626099610305\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"OsNj1626099612133\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"nDBi1626099614032\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"KEVJ1626099615614\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"xNfe1626099617183\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"WpPq1626099584383\"},{\"type\":\"SingleRadio\",\"label\":\"【工作态度】 （必填）\",\"name\":\"TNSr1626099638390\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"uilT1626099642094\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"fbFM1626099643889\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"FxUw1626099645689\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"eGQi1626099647287\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"yJcR1626099648839\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"HfMd1626099638390\"},{\"type\":\"SingleRadio\",\"label\":\"【业务理解能力】 （必填）\",\"name\":\"hUJR1626099670100\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"RShw1626099677834\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"ZoWF1626099679733\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"GqCr1626099681504\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"XfYd1626099682966\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"MzuV1626099684791\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"nnke1626099670100\"},{\"type\":\"SingleRadio\",\"label\":\"【问题分析和解决能力】 （必填）\",\"name\":\"bdYG1626099703817\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"Ahmj1626099711923\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"GvDg1626099713656\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"AvDg1626099715648\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"buNw1626099717231\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"IGnC1626099718702\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"WirP1626099703817\"},{\"type\":\"SingleRadio\",\"label\":\"【沟通能力】 （必填）\",\"name\":\"MRqd1626099786545\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"mEYp1626099791557\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"tEbP1626099795386\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"qNyE1626099797165\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"zstI1626099798782\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"XJqE1626099800407\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"Ymjp1626099786545\"},{\"type\":\"SingleRadio\",\"label\":\"【企业文化践行】 （必填）\",\"name\":\"lRNb1626099845955\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"nIEC1626099850495\",\"label\":\"A\",\"repeatKey\":false},{\"value\":\"stjL1626099852289\",\"label\":\"B\",\"repeatKey\":false},{\"value\":\"zpHY1626099854150\",\"label\":\"C\",\"repeatKey\":false},{\"value\":\"Adgp1626099855670\",\"label\":\"D\",\"repeatKey\":false},{\"value\":\"yCIK1626099857160\",\"label\":\"E\",\"repeatKey\":false}],\"required\":true},\"key\":\"zKPO1626099845955\"},{\"type\":\"QuestionInput\",\"label\":\"对员工试用期期间工作成绩评价 （必填）\",\"name\":\"INwB1626099874018\",\"value\":\"\",\"title\":\"文本题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"required\":true,\"width\":\"24\"},\"key\":\"FVpQ1626099874018\"},{\"type\":\"QuestionInput\",\"label\":\"对员工今后的期望（能力目标和业绩目标） （必填）\",\"name\":\"Egqv1626099886511\",\"value\":\"\",\"title\":\"文本题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"required\":true,\"width\":\"24\"},\"key\":\"CXKi1626099886511\"},{\"type\":\"SingleRadio\",\"label\":\"请对员工的试用期表现进行综合评分（必填）\",\"name\":\"iQOb1626099908426\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"pgBx1626099916284\",\"label\":\"A：优秀\",\"repeatKey\":false},{\"value\":\"sHtB1626099920502\",\"label\":\"B：良好\",\"repeatKey\":false},{\"value\":\"IFGC1626099922189\",\"label\":\"C：合格\",\"repeatKey\":false},{\"value\":\"tABs1626099923522\",\"label\":\"D：部分合格\",\"repeatKey\":false},{\"value\":\"KCgK1626099925069\",\"label\":\"E：不符合标准\",\"repeatKey\":false}],\"required\":true},\"key\":\"mcjH1626099908426\"},{\"type\":\"SingleRadio\",\"label\":\"5. 请选择试用期转正审批结果\\n（如同意员工转正，请选择“通过”；如不同意员工转正，请选择“不通过”，并及时与部门HRBP沟通员工不转正的情况，安排员工离职事宜。） （必填）\",\"name\":\"gSfn1626099934690\",\"value\":\"\",\"title\":\"单选题名称\",\"showDeleteIcon\":false,\"attributes\":{\"emptyError\":false,\"width\":\"24\",\"options\":[{\"value\":\"kSxs1626099945617\",\"label\":\"通过\",\"repeatKey\":false},{\"value\":\"GtPB1626099950746\",\"label\":\"不通过\",\"repeatKey\":false}],\"required\":true},\"key\":\"xHSN1626099934690\"}]\t"

                ;

        // 使用Jackson库解析Json
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode jsonNode = objectMapper.readTree(jsonStr);

        int idx = 0;
        // 遍历JsonNode中的每一项
        for (int i = 0; i < jsonNode.size(); i++) {
            // 获取每一项的值
            String type = jsonNode.get(i).get("type").asText();
            String label = jsonNode.get(i).get("label").asText();
            // 根据需要获取其他属性的值
            // ...
            System.out.println("type: " + type);
            System.out.println("label: " + label);
            if (type.equals("SingleRadio")) {
                // 修改 type 为 Subject 的 value 值
//                ((ObjectNode) jsonNode.get(i)).put("value", strings[idx]);
                idx++;
            }
        }
        String modifiedJsonStr = objectMapper.writeValueAsString(jsonNode);
        System.out.println(modifiedJsonStr);

    }

    public static int[] getNextSecondLargest(int[] nums) {
        int n = nums.length;
        int[] result = new int[n];
        Arrays.fill(result, -1); // 初始化结果数组为-1

        Stack<Integer> stack = new Stack<>();

        for (int i = 0; i < n; i++) {
            while (!stack.isEmpty() && nums[i] > nums[stack.peek()]) {
                int index = stack.pop();
                if (!stack.isEmpty()) {
                    result[index] = nums[i];
                }
            }
            stack.push(i);
        }

        // 处理剩余的元素，它们没有右侧第二个大数
        while (!stack.isEmpty()) {
            stack.pop();
        }

        return result;
    }


}

class person {
    int a = 0;

    public void getBiz() {
        System.out.println("person getBiz, className: " + this.getClass().getSimpleName());
    }
}

class student1 extends person {
    public void getBiz() {
        System.out.println("student1 getBiz, className: " + this.getClass().getSimpleName());
    }
}

class student extends person {
}
